<?php

namespace app\admin\controller;

use app\admin\BaseController;
use app\model\TaskSendImgModel;
use think\facade\Config;
use think\facade\Filesystem;

class Upload extends BaseController
{
    public function index()
    {
        $file = $this->request->file('file');

        $saveName = Filesystem::disk('public')->putFile('img', $file);

        if ($saveName === false) {
            return show_serve([],'请重试',1);
        }
        $config = Config::get('filesystem');

        $reportImgModel = TaskSendImgModel::create([
            'img_url' => $config['disks']['public']['url'].'/'.$saveName,
            'host' => $this->request->domain()
        ]);
        return show_serve($reportImgModel);


    }

}